/**
 * 
 */
package ua.kpi.javatrainee6.model.people;

import ua.kpi.javatrainee6.model.utils.*;
import java.util.Date;

/**
 * Abstract class, represents abstract entity for Student, Professor,
 * Administrator classes
 */
public abstract class Person {
	
	private static int id = 0;
	private String firstName;
	private String lastName;
	private String phoneNumber;
	private Date birthDay;
	private Address homeAddress;
	
	/**
	 * Optional constructor, used now for automatic data generation
	 * Generating departments like this: {"firstName1", "lastName1", "phoneNumber1", ...}, 
	 * {"firstName2", "lastName2", "phoneNumber2", ...}
	 * Will be deleted in later versions - when files or databases with data will be added...
	 */
	public Person() {
		id++;
		firstName = "firstName" + id;
		lastName = "lastName" + id;
		phoneNumber = "phoneNumber" + id;
		birthDay = new Date();	
		homeAddress = new Address();
	}
	
	public abstract void viewResponsibilities();
	public abstract double calculateSalary();
	
	/**
	 * @return Name + Surname string, for statistics printing
	 */
	public String getShortDescription() {
		return firstName + " " + lastName;
	}
	
	@Override
	public String toString() {
		return String.format("Name: %s %s\nPhone: %s\nBirthday: %tF\nAddress: %s",
				              firstName, lastName, phoneNumber, birthDay, homeAddress);
	}
	
	@Override 
	public boolean equals(Object otherObject) {
		if (this == otherObject) {
			return true;
		}
		if (otherObject == null) {
			return false;
		}
		if (getClass() != otherObject.getClass()) {
			return false;
		}
		Person other = (Person) otherObject;
		return ((firstName.equals(other.firstName) && lastName.equals(other.lastName))
		           && (phoneNumber.equals(other.phoneNumber) && (birthDay.compareTo(other.birthDay) == 0)) 
		           && homeAddress.equals(other.homeAddress));
	}
}

